package com.ocm.mq.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author hqy
 * @Date 24/01/2022
 * @Description 延迟7天收货
 */
@Component
public class OrderReceivedMq {
	/**
	 * 延迟死信释放队列
	 * @return
	 */
	@Bean
	public Queue  receivedReleaseQueue(){
		return new Queue("received.release.received.queue", true, false, false);
	}

	/**
	 *
	 * @return
	 */
	@Bean
	public Binding receivedReleaseBinding(){
		return new Binding(
			"received.release.received.queue",
			Binding.DestinationType.QUEUE,
			"received-event-exchange",
			"received.release",
			null
		);
	}
	/**
	 *	延迟死信队列
	 * @return
	 */
	@Bean
	public Queue receivedDelayQueue(){
		Map<String,Object> args = new HashMap<>(3);
		args.put("x-dead-letter-exchange","received-event-exchange");
		args.put("x-dead-letter-routing-key","received.release");
		args.put("x-message-ttl",80000);
		return new Queue("received.delay.queue", true, false, false,args);
	}
	@Bean
	public Queue  receivedStockQueue(){
		return new Queue("received.stock.received.queue", true, false, false);
	}

	@Bean
	public Binding receivedStockReceivedBinding(){
		return new Binding(
			"received.stock.received.queue",
			Binding.DestinationType.QUEUE,
			"received-event-exchange",
			"received.stock.received",
			null
		);
	}


	@Bean
	public Binding receivedCreateReceivedBinding(){
		return new Binding(
			"received.delay.queue",
			Binding.DestinationType.QUEUE,
			"received-event-exchange",
			"received.create.received",
			null
		);
	}







}
